<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/website/common/base.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${webname }-${channel.name }</title>
<%@ include file="/website/common/common.jsp"%>
<link href="${webctx }/css/list.css" rel="stylesheet" type="text/css" />
	<link href="${webctx }/css/sidebar.css?v=20170616" rel="stylesheet" type="text/css" />

</head>
<script src="${webctx }js/jquery.fly.js"></script>
<body>
<%@ include file="/website/common/top.jsp"%>
<%@ include file="/website/common/head.jsp"%>
<%@ include file="/website/common/menu.jsp"%>
<div id="wrap-special">
	<c:if test="${not empty channel.photo}"><div class="special-banner"><a href="javascript:showlmurl('${channel.url}');"><img src="${fileserver }${channel.photo}"></a></div></c:if>
    <c:forEach items="${channel.sublist }" var="info">
	    <c:if test="${not empty info.photo}">
	    	<div class="special-ad inner mt-20"><a href="javascript:showlmurl('${info.url}');"><img src="${fileserver }${info.photo}" style="max-width:1210px;"/></a></div>
	    </c:if>

		<%--广告图 --%>
	    <div class="special-main inner clearfix">
	        <ul class="array-container">

	        	<c:forEach items="${info.products }" var="product">
	            <li class="array-item pricture-wrap" pid="${product.id }">
	               <div class="array-pic"><a href="${ctx }/product/info?priceid=${product.id}" target="_blank"><img src="${fileserver }${product.photo}" width="200" height="200" onerror="this.src='${ctx }/website/images/noimg.jpg'" title="${product.productname }&nbsp;${product.B_guige }"/></a></div>
	                <div class="array-info">
						<div class="cost clear">
							<c:choose>
								<c:when test="${islogin && isuserauth }">
									<c:if test="${product.canbuy == 1}">
									<strong>¥${product.price }</strong>
									<div class="cost-span">
										<%--<span>券</span>--%>
											<c:if test="${product.promotion_coupon eq 'true'}">
												<span>券</span>
											</c:if>
											<c:if test="${product.promotion_money_off eq 'true'}">
												<span>满减</span>
											</c:if>
											<c:if test="${product.promotion_purchase_gift eq 'true'}">
												<span>满赠</span>
											</c:if>
											<c:if test="${product.promotion_buy_send eq 'true'}">
												<span>买送</span>
											</c:if>
											<c:if test="${product.promotion_flash_sale eq 'true'}">
												<span>特价</span>
											</c:if>

									</div>
									</c:if>
									<c:if test="${product.canbuy != 1}">
										<font color="red">不在本区域销售</font>
									</c:if>
								</c:when><c:when test="${!islogin}"><font color="red">登录可见</font></c:when><c:when test="${!isuserauth}"><font color="red">审核通过可见</font></c:when></c:choose>
						</div>
						<div class="title"><a href="${ctx }/product/info?priceid=${product.id}" target="_blank" title="${product.productname }&nbsp; ${product.B_guige }"><em>${product.productname }</em>&nbsp; ${product.B_guige }</a></div>
						<div class="text clearfix">
	                    	<span class="fl">
							      <c:choose>
									  <c:when test="${fn:length(product.B_chanjia) > 11}">
										  <c:out value="${fn:substring(product.B_chanjia, 0, 11)}..." />
									  </c:when>
									  <c:otherwise>
										  <c:out value="${product.B_chanjia}" />
									  </c:otherwise>
								  </c:choose>
							</span>
						</div>
						<div class="btn clearfix">
							<div class="buy-Num-bd fl">
								<input type="text" name="amount" onkeyup="inputAmount(this)" class="buy-numInp" maxnum="${product.amount }" value="1" style="line-height:20px;">
								<span class="btn-reduce" onclick="lessenamount(this)">-</span>
								<span class="btn-add" onclick="addamount(this)">+</span>
							</div>
							<span class="fl btn-txt"></span>
							<div class="buy-btn fl">
								<c:choose>
									<c:when test="${product.canbuy != 1 || product.amount < 1}">
										<a href="javascript:;" ><i class="fa fa-cart-plus"></i>加入购物车</a>

									</c:when>
									<c:otherwise>
										<a href="javascript:;" onclick="addtocart(event,this,${product.id})" class="can"><i class="fa fa-cart-plus"></i>加入购物车</a>
									</c:otherwise>
								</c:choose>
							</div>
						</div>

	            	</div>
	            </li>
	            </c:forEach>
	        </ul>
	    </div>
    </c:forEach>
    <div class="line8"></div><div class="line8"></div>
</div>
<%@ include file="/website/common/foot.jsp"%>
<%@ include file="/website/common/sidebar.jsp"%>

<script>
function addamount(obj){
  var txt=$("[name='amount']",$(obj).parent());
  var n=parseInt(txt.val());
  n++;
  txt.val(n);
  inputAmount(txt);
}
function lessenamount(obj){
  var txt=$("[name='amount']",$(obj).parent());
  var n=parseInt(txt.val());
  n--;
  txt.val(n);
  inputAmount(txt);
}
function addtocart(event,obj,pid){
	var url=ctx+"/order/addToCart?pid="+pid+"&amount="+$("[name='amount']",$("[pid='"+pid+"']")).val();
	$w.addCartItem(event,obj,url);
}
/*
function addtobuy(pid){
	$w.httpRequest({
		url:apiroot+"/order/generateorder2",
		data:{"data":"[{\"priceid\":"+pid+",\"num\":"+$("[name='amount']",$("[pid='"+pid+"']")).val()+"}]"},
		ok:function(ret){
			var ordercode=ret.Data;
			window.location.href=ctx+"/order/orderconfirm?ordercode="+ordercode;
		},fail:function(ret){if(ret.MsgCode=='1001')window.location.href=ctx+"/user/certification";else alert(ret.MsgDesc);return false}/!*,all:function(){submiting=false;}*!/
	});
    addtocart(pid);

}*/
/*//添加购物车
function addCart(obj,event) {
    var img = $(obj).parents(".pricture-wrap").find('img').attr('src');
    var scorll_top = $(document).scrollTop();

    var offset = $('#carbox').offset(),
        flyer = $('<img class="u-flyer" src="'+ img +'"/>');
    flyer.fly({
        start: {
            left: event.pageX,
            top: event.pageY - scorll_top
        },
        end: {
            left: offset.left,
            top: offset.top - scorll_top,
            width: 20,
            height: 20
        },
        onEnd: function() {
            flyer.fadeOut('slow', function() {
                $(this).remove();
            })
        }
    });
}*/
function showlmurl(url){
	if(url)window.open(url)
}
</script>
</body>
</html>
